home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / opbonus.arc / TESTREPL.ARC / TESTREPL.PAS < prev   
Pascal/Delphi Source File  |  1991-03-20  |  2KB  |  58 lines

  1. (*
  2.  This small program demonstrates how to combine OPREPLAY and OPSWAP to create
  3.  a swappable TSR that can play macros for an underlying application. One
  4.  critical point to note is that the TSR's main unit -- REPLMAIN in this
  5.  example -- CANNOT use OPREPLAY in its USES statement. Doing so causes
  6.  OPREPLAY to link into memory so that it is swapped OUT when the TSR pops
  7.  down. As a result, the interrupt 16h handler would be overwritten by the
  8.  underlying application and a crash would occur.
  9.  
  10.  Procedure pointers are used to avoid this problem. Note how the main block of
  11.  TESTREPL assigns the addresses of the needed routines in OPREPLAY to the
  12.  procedure variables in the interface section of REPLMAIN. In this way,
  13.  routines in REPLMAIN can call those OPREPLAY routines without needing to use
  14.  the unit directly. If your program needs access to more routines from
  15.  OPREPLAY, just declare more procedure variables in REPLMAIN and initialize
  16.  them from the main block of TESTREPL.
  17.  
  18.  Also make special note of the steps required to unload such a TSR from
  19.  memory.
  20.  
  21.  There are a few other tricky things in this demonstration program. If you use
  22.  it as a starting point for a similar TSR, you won't need to worry about all
  23.  these details.
  24.  
  25.  TurboPower Software
  26.  Written 3/8/90
  27.  Updated 5/22/90
  28.    edit REPLMAIN to allow unloading when in non-swapping mode
  29. *)
  30.  
  31. {$R-,S-,F-,A-}
  32. {$M 2048,0,655360}
  33.  
  34. program TestRepl;
  35.  
  36. uses
  37.   Dos,
  38.   ReplMain,
  39.   OpSwap,
  40.   OpReplay;
  41.  
  42. begin
  43.   {Save int 16 vector and install OPREPLAY's}
  44.   GetIntVec($16, SaveInt16);
  45.   SetIntVec($16, @OpReplay.Int16);
  46.  
  47.   {Initialize procedure variables in REPLMAIN}
  48.   @CallStartMacro := @OpReplay.StartMacro;
  49.   CallStringToScrapMacro := OpReplay.StringToScrapMacro;
  50.  
  51.   {Use the 127 character scrap macro for storage, and let REPLMAIN know it}
  52.   InitScrapMacroPtr;
  53.   MacPtr := OpReplay.ScrapMacroPtr;
  54.  
  55.   {Go resident}
  56.   InitializeTest;
  57. end.
  58.